'use strict'

const path = require('path')
const fs = require('fs')
const url = require('url')

const appDirectory = fs.realpathSync(process.cwd());
const resolveApp = relativePath => path.resolve(appDirectory,relativePath)

const envPublicUrl = process.env.PUBLIC_URL
const appName = envPublicUrl && envPublicUrl.split("/").reverse()[0]

function ensureSlash(path,needsSlash){
    const hasSlash = path.endsWith("/")
    if(hasSlash && !needsSlash){
        return path.substr(path,path.length -1)
    }else if(!hasSlash && needsSlash){
        return `${path}/`
    }else{
        return path;
    }
}

function getServedPath (appPackageJson){
    const publicUrl = getPublicUrl(appPackageJson);
    //const servedUrl = envPublicUrl || public
}

const getPublicUrl = appPackageJson => envPublicUrl || require(appPackageJson).homepage;

console.log(path.dirname);

module.exports={
    dotenv:resolveApp('.env'),
    appPublic:resolveApp('public'),
    appSrc:resolveApp('src'),
    appHtml:resolveApp('public/index.html'),
    appIndexJs:resolveApp('src/index.js'),
    appPackageJson:resolveApp('package.json'),
    appNodeModules:resolveApp('node_modules')
}